﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Scan
{
    static class Program
    {
        private static NLog.Logger logger = NLog.LogManager.GetLogger("Program");
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [MTAThread]
        static void Main()
        {
            try
            {
                //全屏显示
                IntPtr hWnd = Win32.FindWindow("HHTaskBar", null);
                if (hWnd != IntPtr.Zero)
                {
                    Win32.ShowWindow(hWnd, 0);
                }
                Win32.SystemParametersInfo(47, 0, 0, 0x0002);

                logger.Info("application start");
                Application.Run(new MainForm());
                Configuration.Instance.SetValue(ConfigurationKeys.ExitDateTime, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                logger.Info("application stop");
            }
            catch (Exception ex)
            {
                logger.ErrorException("程序中出现异常", ex);
            }
            finally
            {
                try
                {
                    IntPtr hWnd = Win32.FindWindow("HHTaskBar", null);
                    if (hWnd != IntPtr.Zero)
                    {
                        Win32.ShowWindow(hWnd, 1);
                    }
                }
                catch { }
            }
        }
    }
}